<template>
    <div>
        <div style="height:2rem; background-color: rgba(255, 243, 238, 1);">
            <p style="height:100%;line-height:2rem;color:#EF5423;" v-if="lengths">
                用餐门店距离您{{countLength().toFixed(2)}}km，请安排好到店时间
            </p>
            <div style="height:100%;line-height:2rem;color:#EF5423;" v-else>
				<div style="width:4%;height:50%;display:inline-block;position:relative;">
					<img data-v-05b40818="" src="../../../../static/image/homeLoading.gif" style="width: 0.7rem;position:absolute;top:0.4rem;">
				</div>
				<span style="display:inline-block;">定位中...</span> 
            </div>
        </div>
    </div>
    
</template>

<script>
	import axios from "axios";
	// import api from "../../api";
	import {Popup, MessageBox} from 'mint-ui';
	import { mapState, mapGetters, mapMutations } from "vuex";
	export default {
		data(){
			return {
				ParentOrderNos:"",
				rids:'',
				lengths:null,
                
			}
		},
      	props: {
//	      	orderNo: {
//		        type: String,
//	//		        default: () => {
//	//		          return false
//	//		        }
//		        required:true
//		    },
	// 	    types: {
	// 	        type: Boolean,
	// //		        default: () => {
	// //		          return false
	// //		        }
	// 	        required:true
	// 	    },
	    },
	    computed: {
	    	getBillList() {
                return this.$store.state.hzh.getBillInfor;
            },
            getBillContent() {
                return this.$store.state.hzh.BillContent;
            },
            
	    },
		components:{

		},
		watch:{
			lengths(newData,oldData){
				console.log(oldData,newData,"新老数据-----------++++++++++++++++++++++++++-----------------------------------------------")
			}
		},
		methods: {
           countLength(){
                let currentPos = localStorage.getItem("currentPos");
                let storeLat = localStorage.getItem("storeLat");
                let storeLng = localStorage.getItem("storeLng");
                let poslat = localStorage.getItem("poslat");
                let poslng = localStorage.getItem("poslng");
                this.lengths = calculate(Number(poslat),Number(poslng),Number(storeLat),Number(storeLng))
                return this.lengths;

               /*根据经纬度计算距离，单位是千米*/
				function calculate(lat1, lng1, lat2, lng2) {
					var radLat1 = lat1 * Math.PI / 180.0;
					var radLat2 = lat2 * Math.PI / 180.0;
					var a = radLat1 - radLat2;
					var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
					var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
					s = s * 6378.137;
					s = Math.round(s * 10000) / 10000;
					return s
				};
				/*给出结果*/
				function end(param1, param2) {
					var result = [];
					for(var i in param1) {
						for(var j in param2) {
							if(calculate(param1[i].lat, param1[i].lng, param2[j].lat, param2[j].lng) < param2[j].long) {
								result.push(i);
							}
						}
					}
					return result;
				}
           }
	            
	         
	     
			
        },
        created(){
            this.countLength();
        },
		mounted() {
			
		},
	}
	
</script>

<style>

</style>